
var token=wx.getStorageSync('token')
// var commonAPI=require('../api/Common')
module.exports={
  addScore:async function (score) {
  //   var score={
  //     "scoreId": "",
  //     "type": type,
  //     "userId": "",
  //     "relationId": relationId,
  //     "score": score,
  //     "reason": reason
  // }
   var res= await wx.cloud.callContainer({
    "config": {
      "env": "prod-3gfrot0nb41198bc"
    },
    "path": "/api/score",
    "header": {
      "X-WX-SERVICE": "springboot-zd5r",
      "content-type": "application/json",
      "token": token
    },
    "method": "POST",
    "data": score
  }).then((res)=>{
    return res
  })
  return res

  },
  deleteScore:async function (scoreId) {
  var res= await  wx.cloud.callContainer({
      "config": {
        "env": "prod-3gfrot0nb41198bc"
      },
      "path": "/api/score/"+scoreId,
      "header": {
        "X-WX-SERVICE": "springboot-zd5r",
        "content-type": "application/json",
        "token": token
      },
      "method": "DELETE",
      "data": ""
    }).then((res)=>{
      return res
    })
    return res
  },
  updateScore:async function (score) {
  //   var score={
  //     "scoreId": scoreId,
  //     "type": type,
  //     "userId": "",
  //     "relationId": "",
  //     "score": score,
  //     "reason": reason
  // }
   var res= wx.cloud.callContainer({
      "config": {
        "env": "prod-3gfrot0nb41198bc"
      },
      "path": "/api/score/",
      "header": {
        "X-WX-SERVICE": "springboot-zd5r",
        "content-type": "application/json",
        "token": token
      },
      "method": "PUT",
      "data": score
    })
    return res
  },
  getScore: async function (relationTypeId,userTypeId,page,size) {
    var reqLimit={
      "page": page,
      "size": size
  }
    var path="/api/score/"+relationTypeId+"/"+userTypeId+"?reqLimit="+JSON.stringify(reqLimit)
    path=encodeURI(path)
    console.log(path)
    var res= await wx.cloud.callContainer({
      "config": {
        "env": "prod-3gfrot0nb41198bc"
      },
      "path": path,
      "header": {
        "X-WX-SERVICE": "springboot-zd5r",
        "content-type": "application/json",
        "token": token
      },
      "method": "GET",
      "data": ""
    }).then((res)=>{    
      return res
    }).catch((error)=>{console.log(console.log(error))})
    return res
  },
 


}